#pragma once
#include "beacon_loc.h"
#include <list>
//#include "BeaconInterface.h"
namespace easyshow{
	
	class LocatorWrapper{
	public:
		static LocatorWrapper* LocaterWrapperInstance()
		{
			if (LocatorWrapperInst == NULL)
			{
				LocatorWrapperInst = new LocatorWrapper();
			}
			return LocatorWrapperInst;
		}

		bool init(std::string config_fn, bool reset)
		{
			return beaconMgr.init(config_fn, reset);
		}

		void PushLocationData(std::vector<BeaconData> beacon_datas)
		{
			UserPos pos = beaconMgr.predictPosition(beacon_datas);
			//perhaps data pos need to sort
			LocatoinPosArray.push_back(pos);
		}

		UserPos PopLocationData(bool& get)
		{
			UserPos pos;
			if (LocatoinPosArray.size() > 0)
			{
				pos = LocatoinPosArray.front();
				//LOGI("PopLocationData coun is %d posx is %f,posy is %f ,mapid is %d", LocatoinPosArray.size(), pos.pos_x, pos.pos_y, pos.map_id);
				
				LocatoinPosArray.pop_front();
				get = true;
			}
			else{
				get = false;
			}
			return pos;
		}

	private:
		std::list<UserPos> LocatoinPosArray;
		BeaconLocator  beaconMgr;
		static LocatorWrapper *LocatorWrapperInst;
	};

	
}
